<template>
  <a-tabs v-model:value="value" @change="change">
    <a-tab-pane v-for="(item, index) of dataSource" :key="item.key || index" :tab="item.label" tab-position="top">
      <slot v-if="item.key" :name="item.key" :item="item" :index="index" />
    </a-tab-pane>
  </a-tabs>
</template>

<script>
import useGroup, { GROUP_PROPS } from '../mixins/useGroup.js';

export default {
  name: 'tabs-group',
  emits: ['change'],
  props: GROUP_PROPS,
  setup(props, ctx) {
    const { dataSource, value, getData, output } = useGroup(props, ctx);
    const change = function (key) {
      output(key, getData('key', key, 'value'));
    };
    return { dataSource, value, change };
  },
};
</script>

<style lang="less"></style>
